//
//  RAPEmoticonButton.swift
//  COPYCAT-Weibo
//
//  Created by 闫萌 on 1/8/16.
//  Copyright © 2016 RendezvousAuParadis. All rights reserved.
//

import UIKit

class RAPEmoticonButton: UIButton {

    var emoticonModel: RAPEmoticonModel? {
        didSet {
            guard let emo = emoticonModel else {
                return
            }
            if emo.type == "0" { // 图片表情
                setTitle(nil, forState: UIControlState.Normal) // 图片表情要将title设置为空
                setImage(UIImage(named: emo.png!, inBundle: RAPEmoticonKeyboardViewModel.sharedViewModel.emoticonBundle, compatibleWithTraitCollection: nil), forState: UIControlState.Normal)
            } else if emo.type == "1" { // emoji
                setTitle(emo.code, forState: UIControlState.Normal)
                setImage(nil, forState: UIControlState.Normal) // 文字表情要将image设置为空
            }
        }
    }

}
